package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;
import com.eastfair.projectcore.enumeration.DataIsolationSystemSceneEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 展会相关企业
 * </p>
 *
 * @author dq
 * @date 2022-09-28
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ExhibitionCompanyCompanyTypeEnum", description = "企业类型 #{BUILD_SERVICE_PROVIDER:搭建商;MAIN_TRANSPORT_SERVICE_PROVIDER:主运商;HOME_SERVICE_PROVIDER:主场商;MATCHING_SERVICE_PROVIDER:配套商;SPONSOR:主办方;EXHIBITOR:参展商;OTHERS:其他-枚举")
public enum ExhibitionCompanyCompanyTypeEnum implements BaseEnum {

    /**
     * BUILD_SERVICE_PROVIDER="搭建商"
     */
    BUILD_SERVICE_PROVIDER("搭建商"),
    /**
     * MAIN_TRANSPORT_SERVICE_PROVIDER="主运商"
     */
    MAIN_TRANSPORT_SERVICE_PROVIDER("主运商"),
    /**
     * HOME_SERVICE_PROVIDER="主场商"
     */
    HOME_SERVICE_PROVIDER("主场商"),
    /**
     * MATCHING_SERVICE_PROVIDER="配套商"
     */
    MATCHING_SERVICE_PROVIDER("配套商"),
    /**
     * SPONSOR="主办方"
     */
    SPONSOR("主办方"),
    /**
     * EXHIBITOR="参展商"
     */
    EXHIBITOR("参展商"),
    /**
     * OTHERS="其他"
     */
    OTHERS("其他"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ExhibitionCompanyCompanyTypeEnum match(String val, ExhibitionCompanyCompanyTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ExhibitionCompanyCompanyTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ExhibitionCompanyCompanyTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "BUILD_SERVICE_PROVIDER,MAIN_TRANSPORT_SERVICE_PROVIDER,HOME_SERVICE_PROVIDER,MATCHING_SERVICE_PROVIDER,SPONSOR,EXHIBITOR,OTHERS", example = "BUILD_SERVICE_PROVIDER")
    public String getCode() {
        return this.name();
    }


    public static String getSceneEnum(String serviceProviderTypeEnumStr) {
        ExhibitionCompanyCompanyTypeEnum serviceProviderTypeEnum = ExhibitionCompanyCompanyTypeEnum.get(serviceProviderTypeEnumStr);
        if (Objects.nonNull(serviceProviderTypeEnum)) {
            if (ExhibitionCompanyCompanyTypeEnum.BUILD_SERVICE_PROVIDER.equals(serviceProviderTypeEnum)) {
                return DataIsolationSystemSceneEnum.P_COMPOSITE_PRODUCER.getCode();
            } else if (ExhibitionCompanyCompanyTypeEnum.MAIN_TRANSPORT_SERVICE_PROVIDER.equals(serviceProviderTypeEnum)) {
                return DataIsolationSystemSceneEnum.P_COMPOSITE_TRANSPORT.getCode();
            } else if (ExhibitionCompanyCompanyTypeEnum.HOME_SERVICE_PROVIDER.equals(serviceProviderTypeEnum)) {
                return DataIsolationSystemSceneEnum.P_COMPOSITE_COURT.getCode();
            } else if (ExhibitionCompanyCompanyTypeEnum.MATCHING_SERVICE_PROVIDER.equals(serviceProviderTypeEnum)) {
                return DataIsolationSystemSceneEnum.P_COMPOSITE_MATING.getCode();
            }
        }
        return serviceProviderTypeEnumStr;
    }

}
